package com.chang.bootplus.controller;


import com.chang.bootplus.base.utils.ApiResponse;
import com.chang.bootplus.po.EvaluateListPO;
import com.chang.bootplus.po.EvaluatePO;
import com.chang.bootplus.po.LoveNumPO;
import com.chang.bootplus.po.LovePO;
import com.chang.bootplus.service.EvaluateService;
import com.chang.bootplus.vo.EvaluateVO;
import com.chang.bootplus.vo.LoveVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chang
 * @since 2022-01-06
 */

@RestController
@Api(tags = {"用户评论"})
@CrossOrigin(origins = "*")
@RequestMapping("/evaluate")
public class EvaluateController {

    @Autowired
    EvaluateService evaluateService;

    @PostMapping("getlovenum")
    @ApiOperation(httpMethod = "POST",value = "获取评论点赞数")
    public ApiResponse<LoveVO> getLoveNum(@RequestBody LoveNumPO po){
        return evaluateService.getLoveNum(po);
    }

    @PostMapping("comment")
    @ApiOperation(httpMethod = "POST",value = "发布评论")
    public ApiResponse<Void> comment(@RequestBody EvaluatePO po){
        return evaluateService.comment(po);
    }

    @PostMapping("list")
    @ApiOperation(httpMethod = "POST",value = "展示评论")
    public ApiResponse<EvaluateVO> listComment(@RequestBody EvaluateListPO po){
        return evaluateService.listComment(po);
    }

    @PostMapping("love")
    @ApiOperation(httpMethod = "POST",value = "给评论点赞/再次调用为取消点赞")
    public ApiResponse<Void> loveComment(@RequestBody LovePO po){
        return evaluateService.loveComment(po);
    }

    @PostMapping("delete")
    @ApiOperation(httpMethod = "POST",value = "评论删除")
    public ApiResponse<Void> deleteComment(@RequestBody EvaluateListPO po){
        return evaluateService.deleteComment(po);
    }

    @PostMapping("backmessage")
    @ApiOperation(httpMethod = "POST",value = "回复评论")
    public ApiResponse<Void> backComment(@RequestBody EvaluatePO po){
        return evaluateService.backComment(po);
    }


}

